package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.pojo.Empl;
import com.gxa.service.loginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author xiejinfeng
 * @create 2021-06-07 11:44
 * @descrip:
 */
@Controller
@RequestMapping("login")
public class LoginController {

    @Autowired
    private loginService loginService;

    @GetMapping("/page")
    public String page(){
        return "login";
    }

    @PostMapping("/do")
    @ResponseBody
    public R login(Empl empl, HttpSession session){
        return loginService.login(empl,session);
    }

    @PostMapping("/out")
    @ResponseBody
    public R logout(HttpSession session){
        // 清空数据
        session.removeAttribute("emplName");
        return new R(200, "退出成功！");
    }

}
